/*************************************************************************
	> File Name: execve.c
	> Author: Angel Criss
	> Blog: blog.abbycin.tk 
	> Created Time: Wed 09 Jul 2014 10:05:27 AM CST
 ************************************************************************/

#include"head.h"
#include<string.h>
int main(int argc,char *argv[])
{
    //char *evironment[]={"name: abby","site: abbycin.tk","GoodBye",NULL};
    char *pathname=argv[1];
    char *parameter[5]; // have to declare the size

    parameter[0]=strrchr(argv[1],'/'); // locate the last occurence of '/'

    parameter[1]="this is a test";
    parameter[2]="made by abby";
    parameter[3]="this is the end";
    parameter[4]="Thank You!";

    switch(fork())
    {
        case -1:
            err("fork");
        case 0:
            //execve(argv[1],parameter,evironment);
            execve(argv[1],parameter,NULL);
            _exit(EXIT_SUCCESS);
        default:
            sleep(3);
            wait(NULL);
            printf("all done\n");
    }
    if(errno)
        err("execve");
}
